package hashfunctions;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.BitSet;

public class HashSHA1BN_128 extends HashFunction_128 {

	 public String hash(String clearTextPassword)
     throws NoSuchAlgorithmException
	{
		  return Hash.bitSetToString(hashBitSet(clearTextPassword));
	}


	public BitSet hashBitSet(String palabra) throws NoSuchAlgorithmException {
		BitSet output=new BitSet(128);
		MessageDigest md = MessageDigest.getInstance("SHA-1");
		
		md.update(palabra.getBytes());
		
		byte[] sss=md.digest();
			for(int i=0; i<sss.length;i++){
				output.set((int) Math.abs(sss[i])%128);
			}
		return output;
	}
	

	@Override
	public String tipo() {
		return "HashSHA1BN_128";
	}

}
